/*
 * @Author: 葛文杰
 * @Date: 2021/2/20 11:32
 * @Description: egg controller 数据源接口参数
 */

'use strict';

const BaseController = require('./base');


class DataSourceInterfaceParamController extends BaseController {

    /**
     * 获取数据源接口参数列表
     */
    async getInterfaceParamByDataSourceConfigId() {
        const { ctx, service } = this;
        const { body: interfaceParamCondition } = ctx.request;
        const interfaceParamArray =
          await service.dataSourceInterfaceParam.getInterfaceParamByDataSourceConfigId(interfaceParamCondition);
        this.success({ data: interfaceParamArray });
    }

    /**
     * 获取数据源接口参数信息
     */
    async getInterfaceParamInfoById() {
        const { ctx, service } = this;
        const { body: interfaceParamCondition } = ctx.request;
        const interfaceParamInfo =
          await service.dataSourceInterfaceParam.getInterfaceParamInfoById(interfaceParamCondition);
        this.success({ data: interfaceParamInfo });
    }

    /**
     * 获取数据源接口参数信息
     */
    async insertInterfaceParamInfoById() {
        const { ctx, service } = this;
        const { body: interfaceParamCondition } = ctx.request;
        const result =
          await service.dataSourceInterfaceParam.insertInterfaceParamInfoById(interfaceParamCondition);
        this.success({ data: result });
    }

    /**
     * 获取数据源接口参数信息
     */
    async updateInterfaceParamInfoById() {
        const { ctx, service } = this;
        const { body: interfaceParamCondition } = ctx.request;
        const result =
          await service.dataSourceInterfaceParam.updateInterfaceParamInfoById(interfaceParamCondition);
        this.success({ data: result });
    }


    /**
     * 删除数据源接口参数
     */
    async deleteInterfaceParamById() {
        const { ctx, service } = this;
        const { body: interfaceParamCondition } = ctx.request;
        let result =
          await service.dataSourceInterfaceParam.deleteInterfaceParamById(interfaceParamCondition);
        this.success({ data: result });
    }
}

module.exports = DataSourceInterfaceParamController;
